package com.example.study.controller;


import com.example.study.utils.JsonResult;
import com.example.study.utils.MicroServiceUrl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping(value = "log")
public class LogController {

    @Value("${url.orderUrl}")
    private String url;

    @Autowired
    private MicroServiceUrl microServiceUrl;

    private final static Logger logger = LoggerFactory.getLogger(LogController.class);

    @RequestMapping(value = "logPrint")
    public String testLog() {
        logger.info("这是一个info日志");
        logger.debug("这是一个debug日志");
        logger.error("这是一个error日志");
        logger.warn("这是一个警告日志");

        String str1 = "blog";
        String str2 = "csdn";

        logger.info("这是个人日志:{};这也是日志：{}", str1, str2);

        return "success";
    }

    @RequestMapping(value = "valueConfig")
    public JsonResult congfig() {
        logger.info("这是微服务地址:{}", url);
        return new JsonResult<>();

    }

    @RequestMapping(value = "testConfig")
    public JsonResult testCongfig() {
        logger.info("这是微服务地址:{}", microServiceUrl.getOrderUrl());
        return new JsonResult<>();

    }
}
